﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace REVISIONMAX30.Controls
{
    public partial class MyLogList : UserControl
    {
        public MyLogList()
        {
            InitializeComponent();
        }

        public UIHandler uiHandler { get; set; }
        public DataObjects.Group group { get; set; }

        public void Initzialize(UIHandler pUIHandler, DataObjects.Group pParentObject)
        {
            this.uiHandler = pUIHandler;
            this.group = pParentObject;
            this.UpdateViewer();
        }
 
        public void UpdateViewer()
        {
            //this.lvConnectionStrings.Items.Clear();

            //foreach (var tConnectionString in this.group.ConnectionStringList)
            //{
            //    var tvlItem = this.lvConnectionStrings.Items.Add(tConnectionString.Name);

            //    tvlItem.Tag = tConnectionString.DataObjectGUID;
            //    tvlItem.SubItems.Add(tConnectionString.Value);
            //    tvlItem.SubItems.Add(tConnectionString.Created.StringValueOrEmpty());
            //    tvlItem.SubItems.Add(tConnectionString.Updated.StringValueOrEmpty());

            //    if (tConnectionString.TestConnection().Severity == Frame.FrResultSeverityType.Error)
            //    {
            //        tvlItem.BackColor = Color.LightSalmon;
            //    }
            //    else
            //    {
            //        tvlItem.BackColor = Color.LightGreen;
            //    }

            //}
        }

        private void lvLogs_DoubleClick(object sender, EventArgs e)
        {
            //if (this.lvLogs.SelectedItems.Count > 0)
            //{
            //    var tSelectedGUID = (Guid)this.lvLogs.SelectedItems[0].Tag;
            //    this.uiHandler.ViewConnectionString(this.group..Where(t => t.DataObjectGUID == tSelectedGUID).First(), this.group);
            //    this.UpdateViewer();
            //}
        }
    }
}
